package com.daiqile.myinterest.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.daiqile.myinterest.model.AllBankcardList;
import com.daiqile.myinterest.R;

import java.util.List;

/**
 * @author Mr.Bean
 * @date Created on 2017/8/21.
 */

public class AllbankcardAdapter extends RecyclerView.Adapter<AllbankcardAdapter.ViewHolder> {
    private List<AllBankcardList.ListBean>  mDList;
    static class ViewHolder extends RecyclerView.ViewHolder {
        //  View fcView;
        TextView abccardid;
        TextView abcbank;
        TextView abcacc;
        TextView abcbranch;
        public ViewHolder(View view){
            super(view);
            abccardid = (TextView)view.findViewById(R.id.abc_cardid);
            abcacc= (TextView)view.findViewById(R.id.abc_acc);
            abcbank= (TextView)view.findViewById(R.id.abc_bank);
            abcbranch= (TextView)view.findViewById(R.id.abc_branch);
        }
    }
    public AllbankcardAdapter(List<AllBankcardList.ListBean> abcList){
        mDList = abcList;
    }
    public void setDataList(List<AllBankcardList.ListBean> abcList){
        mDList = abcList;
        notifyDataSetChanged();
    }
    public List<AllBankcardList.ListBean> getDataList(){
        return mDList;
    }
    //重写三个方法
//创建实例
    @Override
    public AllbankcardAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.allbankcard_items,parent,false);
        final AllbankcardAdapter.ViewHolder holder = new AllbankcardAdapter.ViewHolder(view);
        return holder;
    }
    //赋值
    @Override
    public void onBindViewHolder(AllbankcardAdapter.ViewHolder holder, int position){
        AllBankcardList.ListBean allbankcard = mDList.get(position);
        holder.abccardid.setText("银行卡记录id:"+allbankcard.getId());
        holder.abcbank.setText("银行id:"+allbankcard.getBank());
        holder.abcacc.setText( "银行卡号:"+allbankcard.getAccount());
        holder.abcbranch.setText("支行:"+allbankcard.getBranch());
    }
    //子项个数
    @Override
    public int getItemCount(){
        return mDList == null?0:mDList.size();
    }
}
